package com.kingdee.pda.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.kingdee.pda.R;
import com.kingdee.pda.entity.ReplenishOrderBean;
import com.kingdee.pda.util.ViewHolder;

/**
 * 补货单信息
 * Created by dlj
 * DATE 2021/6/23
 * TIME 17:38
 */
public class ReplenishOrderAdapter extends AbsBaseAdapter<ReplenishOrderBean.DataBean> {

    public ReplenishOrderAdapter(Context context) {
        super(context);
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.adapter_item_replenish_order, parent, false);
        }
        TextView tv_orderNo = ViewHolder.get(convertView, R.id.tv_orderNo);
        TextView tv_status = ViewHolder.get(convertView, R.id.tv_status);
        TextView tv_number = ViewHolder.get(convertView, R.id.tv_number);
        TextView tv_time = ViewHolder.get(convertView, R.id.tv_time);

        ReplenishOrderBean.DataBean dataBean = getData().get(position);
        tv_orderNo.setText("补货单号：" + dataBean.getBillNo());
        tv_number.setText("期望/实际补货量：" + dataBean.getAllWantQty() + "/" +
                (dataBean.getAllRealQty() == 0 ? "-" : dataBean.getAllRealQty()));
        tv_time.setText(dataBean.getModifyDate());
        if (ReplenishOrderBean.STATUS_WAIT_REPLENISH.equals(dataBean.getBillStatus())) {
            tv_status.setText("待补货");
            tv_status.setTextColor(context.getResources().getColor(R.color.color_01d386));
            tv_status.setBackgroundResource(R.drawable.shape_bg_white_green_side);
        } else if (ReplenishOrderBean.STATUS_IN_REPLENISH.equals(dataBean.getBillStatus())) {
            tv_status.setText("补货中");
            tv_status.setTextColor(context.getResources().getColor(R.color.color_01d386));
            tv_status.setBackgroundResource(R.drawable.shape_bg_white_green_side);
        } else if (ReplenishOrderBean.STATUS_FINISHED_REPLENISH.equals(dataBean.getBillStatus())) {
            tv_status.setText("补货完成");
            tv_status.setTextColor(context.getResources().getColor(R.color.color_01d386));
            tv_status.setBackgroundResource(R.drawable.shape_bg_white_green_side);
        } else if ("A".equals(dataBean.getBillStatus()) || "C".equals(dataBean.getBillStatus())) {
            tv_status.setText("待提交");
            tv_status.setTextColor(context.getResources().getColor(R.color.color_FC8555));
            tv_status.setBackgroundResource(R.drawable.shape_bg_white_orange_side);
        } else if ("B".equals(dataBean.getBillStatus())) {
            tv_status.setText("配货中");
            tv_status.setTextColor(context.getResources().getColor(R.color.color_01d386));
            tv_status.setBackgroundResource(R.drawable.shape_bg_white_green_side);
        } else if ("G".equals(dataBean.getBillStatus())) {
            tv_status.setText("已取消");
            tv_status.setTextColor(context.getResources().getColor(R.color.color_333333));
            tv_status.setBackgroundResource(R.drawable.shape_bg_white_gray_side2);
        }


        return convertView;
    }
}
